package com.tjetc.service.impl;

import com.tjetc.entity.po.Goods;
import com.tjetc.mapper.GoodsMapper;
import com.tjetc.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author gaoyongxiang
 * @version v1.0
 * @since 2025-10-27
 */
@Service
public class IGoodsServiceImpl implements IGoodsService {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @Autowired
    private GoodsMapper goodsMapper;


    @Override
    @Transactional
    public String updateById(Goods goods) {
        // 修改数据库
        goodsMapper.updateById(goods);
        // 删除缓存
        redisTemplate.delete("cache:goods:" + goods.getId());
        return "";
    }

}
